import apiClient from './index';

// 教师列表请求参数
export interface ListTeachersParams {
  class_id?: number; // 可选，班级ID筛选
  name?: string; // 可选，教师姓名筛选
}

// 教师列表项类型
export interface TeacherItem {
  class_role: string;
  subject: string;
  position: string;
  teacher_id: number;
  teacher_name: string;
  teacher_password: string;
  user_id: number;
}

// 教师列表响应类型
export interface ListTeachersResponse {
  code: number;
  content: TeacherItem[];
  msg: string;
}

// 编辑教师参数
export interface EditTeacherParams {
  user_id: number;
  teacher_id: number;
  name: string;
  position: string;
  teacher_password?: string; // 可选，教师口令
  admin_password: string;
}

// 编辑教师响应类型
export interface EditTeacherResponse {
  code: number;
  msg: string;
}

/**
 * 获取教师列表
 */
export const listTeachers = async (
  params: ListTeachersParams
): Promise<ListTeachersResponse> => {
  const response = await apiClient.post<ListTeachersResponse>('/teachermgr/list-teachers', params);
  return response.data;
};

/**
 * 编辑教师信息
 */
export const editTeacher = async (
  params: EditTeacherParams
): Promise<EditTeacherResponse> => {
  const response = await apiClient.post<EditTeacherResponse>('/teachermgr/edit-teacher', params);
  return response.data;
};